package com.unidentifiable._5;

import java.util.stream.IntStream;

/**
 * @author unidentifiable
 * @date 2021/1/19
 */
public class YieldDemo {
    public static void main(String[] args) {
        IntStream.range(0, 2).mapToObj(YieldDemo::test).forEach(Thread::start);
    }

    private static Thread test(int index){
        return new Thread(() -> {
            if (index == 0){
                Thread.yield();
            }
            System.out.println(index);
        });
    }
}
